package demoMod.invincibleOne.cards.invincible;

import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.AbstractPower;
import com.megacrit.cardcrawl.powers.StrengthPower;
import demoMod.invincibleOne.InvincibleOneMod;
import demoMod.invincibleOne.enums.AbstractCardEnum;
import demoMod.invincibleOne.enums.CardTagsEnum;

@Deprecated
public class LimitBreak extends AbstractInvincibleCard {
    public static final String ID = InvincibleOneMod.makeID("LimitBreak");

    private static final CardStrings cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    public static final String NAME = cardStrings.NAME;
    public static final String DESCRIPTION = cardStrings.DESCRIPTION;
    public static final String IMG_PATH = "cards/todo";

    private static final CardType TYPE = CardType.SKILL;
    private static final CardRarity RARITY = AbstractCardEnum.LEGENDARY;
    private static final CardTarget TARGET = CardTarget.ALL_ENEMY;

    private static final int COST = -2;

    public LimitBreak() {
        super(ID, NAME, InvincibleOneMod.getResourcePath(IMG_PATH), COST, DESCRIPTION, TYPE, RARITY, TARGET);
        this.tags.add(CardTagsEnum.VIRUS);
        this.isEthereal = true;
    }

    @Override
    public Runnable getUpgradeAction() {
        return () -> {
            this.rawDescription = cardStrings.UPGRADE_DESCRIPTION;
            this.initializeDescription();
            this.isEthereal = false;
        };
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        AbstractMonster target = null;
        int maxStrength = Integer.MIN_VALUE;
        for (AbstractMonster monster : AbstractDungeon.getMonsters().monsters) {
            if (monster.hasPower(StrengthPower.POWER_ID)) {
                AbstractPower strength = monster.getPower(StrengthPower.POWER_ID);
                if (strength.amount > maxStrength) {
                    maxStrength = strength.amount;
                    target = monster;
                }
            }
        }
        if (target != null) {
            addToBot(new ApplyPowerAction(target, target, new StrengthPower(target, maxStrength)));
        }
    }
}
